#include <iostream>
#include <pjsua2.hpp>

using std::cout;
using std::endl;
using namespace pj;

int main()
{
	Endpoint *ep = new Endpoint;//singlepoint

	Version ver = ep->libVersion();
	cout << "Version:" << ver.major <<"." << ver.minor << endl;
	
	try
	{
		ep->libCreate();
	}
	catch(Error& err) 
	{
		cout << "Startup error:" << err.info() << endl;
	}

	EpConfig ep_cfg;
	ep_cfg.uaConfig.maxCalls = 4;
	ep_cfg.logConfig.level = 5;
	ep_cfg.medConfig.sndClockRate = 16000;

	try
	{
		ep->libInit(ep_cfg);
	}
	catch(Error& err) 
	{
		cout << "Initialization error:" << err.info() << endl;
	}

	cout << "IsThreadRegistered:" << ep->libIsThreadRegistered() << endl;

	//create transport
	try
	{
		TransportConfig tcfg;
		tcfg.port = 5060;

		TransportId tid = ep->transportCreate(PJSIP_TRANSPORT_TCP,tcfg);
	}
	catch(Error& err) 
	{
		cout << "Transport creation error:" << err.info() << endl;
	}

	try
	{
		ep->libStart();
	}
	catch(Error& err)
	{
		cout << "Startup error:" << err.info() << endl;
	}

	ep->libDestroy();

	delete ep;
	
	return 0;
}
